﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameBase;
using Microsoft.Xna.Framework;
using GameBase.Form.Control;

namespace GalaxyPresident
{
    public struct GAME_INFO
    {
        public int myColorIndex;
        public int numberOfTeam;
        public int gameLevel;
        public int numberOfSolarSystem;
        public float moneyAmount;
        public float energyAmount;
        public float meterialAmount;
    }

    class SinglePlayScreen : MenuScreen
    {
        GAME_INFO _gameInfo;
        MyCombobox comboColor;
        MyNumberBox numboxPlayer;
        MyNumberBox numboxResource;
        MyNumberBox numboxMoney;
        MyNumberBox numboxSolarSystem;

        public SinglePlayScreen(Game1 game)
            : base(game)
        {
            _gameInfo.myColorIndex = 0;
            _gameInfo.numberOfTeam = 4;
            _gameInfo.numberOfSolarSystem = 15;
            _gameInfo.gameLevel = 0;
            _gameInfo.moneyAmount = 10000;
            _gameInfo.meterialAmount = 10000;
            _gameInfo.energyAmount = 10000;

        }
        protected override void  InitControl()
        {
            
            MyButton buttonBack = new MyButton(new Vector2(50, 500), "Back");
            buttonBack.SetRandomColor();
            buttonBack.MouseReleasedCallBack = buttonButtonBack;
            panel.Add(buttonBack);

            MyButton buttonStart = new MyButton(new Vector2(50, 50), "Start");
            buttonStart.SetRandomColor();
            buttonStart.MouseReleasedCallBack = buttonButtonStart;
            panel.Add(buttonStart);

            /*MyLabel label = new MyLabel(new Vector2(50, 500),
                "Other stuff",
                50);
            contentPanel.Add(label);*/


            contentPanel.Add(new MyLabel(new Vector2(20, 50), "Preset", FORCOLOR));
            MyCombobox comboPreset = new MyCombobox(new Vector2(300, 50));
            comboPreset.Color = CONTROL_COLOR;
            comboPreset.AddString("Space War", Color.PaleTurquoise);
            comboPreset.AddString("<...>", Color.PaleTurquoise);
            comboPreset.SelectedIndex = 0;
            contentPanel.Add(comboPreset);

            contentPanel.Add(new MyLabel(new Vector2(20, 125), "Player Color", FORCOLOR));
            comboColor = new MyCombobox(new Vector2(300, 125));
            comboColor.IsColorStyle = true;
            comboColor.Color = Constant.teamColors[0];
            for (int i = 0; i < Constant.teamColors.Length; i++)
            {
                comboColor.AddString("Color" + i.ToString(), Constant.teamColors[i]);

            }
            comboColor.SelectedIndex = 0;
            contentPanel.Add(comboColor);

            contentPanel.Add(new MyLabel(new Vector2(20, 175), "No. Other Player", FORCOLOR));
            numboxPlayer = new MyNumberBox(new Vector2(300, 175));
            numboxPlayer.Color = CONTROL_COLOR;
            numboxPlayer.Min = 1;
            numboxPlayer.Value = 3;
            numboxPlayer.Max = 7;
            contentPanel.Add(numboxPlayer);
            
            contentPanel.Add(new MyLabel(new Vector2(20, 250), "No. SolarSystem", FORCOLOR));
            numboxSolarSystem = new MyNumberBox(new Vector2(300, 250));
            numboxSolarSystem.Color = CONTROL_COLOR;
            numboxSolarSystem.Min = 10;
            numboxSolarSystem.Value = 15;
            numboxSolarSystem.Max = 40;
            contentPanel.Add(numboxSolarSystem);
            
            contentPanel.Add(new MyLabel(new Vector2(20, 300), "Start Money", FORCOLOR));
            numboxMoney = new MyNumberBox(new Vector2(300, 300));
            numboxMoney.Color = CONTROL_COLOR;
            numboxMoney.Min = 1000;
            numboxMoney.Max = 10000;
            numboxMoney.Step = 100;
            numboxMoney.Value = 5000;
            
            contentPanel.Add(numboxMoney);

            contentPanel.Add(new MyLabel(new Vector2(20, 350), "Start Resource", FORCOLOR));
            numboxResource = new MyNumberBox(new Vector2(300, 350));
            numboxResource.Color = CONTROL_COLOR;
            numboxResource.Min = 1000;
            numboxResource.Max = 10000;
            numboxResource.Step = 100;
            numboxResource.Value = 5000;
            
            contentPanel.Add(numboxResource);
        }
        private void buttonButtonBack(MyControl sender)
        {
            ChangeScreen( new MainMenuScreen(Game));
        }
        private void buttonButtonStart(MyControl sender)
        {
            _gameInfo.gameLevel = 0;
            _gameInfo.myColorIndex = comboColor.SelectedIndex;
            _gameInfo.numberOfTeam = numboxPlayer.Value + 1;
            _gameInfo.numberOfSolarSystem = numboxSolarSystem.Value;
            _gameInfo.moneyAmount = numboxMoney.Value;
            _gameInfo.energyAmount = numboxResource.Value;
            _gameInfo.meterialAmount = numboxResource.Value;
            
            ChangeScreen(new LoadingScreen(Game, _gameInfo));
        }
    }
}
